package com.diankangwo.factory.service.impl;

import com.diankangwo.factory.dao.TdPropertyMapper;
import com.diankangwo.factory.entity.TdProperty;
import com.diankangwo.factory.service.TdPropertyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/** 商品属性接口实现类
 * Created by wuye on 2017/9/15.
 */
@Service("TdPropertyService")
public class TdPropertyServiceImpl implements TdPropertyService{

    @Autowired
    private TdPropertyMapper mapper;

    /**
     * 根据商品ID查询属性
     */
    @Override
    public List<TdProperty> queryByComid(int comId) {
        return mapper.queryByComid(comId);
    }

    /**
     * 添加商品属性
     * @param tdProperty
     */
    @Override
    @Transactional
    public void save(TdProperty tdProperty) {
        mapper.insert(tdProperty);
    }

    /**
     * 修改商品属性
     * @param tdProperty
     * @return
     */
    @Override
    @Transactional
    public int update(TdProperty tdProperty) {
        return mapper.updateByPrimaryKey(tdProperty);
    }

    /**
     * 删除商品属性
     * @param id
     */
    @Override
    @Transactional
    public void delete(int id) {
        mapper.deleteByPrimaryKey(id);
    }

    @Override
    public TdProperty selectByPrimaryKey(Integer id) {
        return mapper.selectByPrimaryKey(id);
    }
}
